package com.faxsun.core.web.order.security;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.broadleafcommerce.common.security.BroadleafAuthenticationFailureHandler;
import org.springframework.security.core.AuthenticationException;

import com.faxsun.core.web.security.service.FraudService;

public class FSAuthenticationFailureHandler extends
		BroadleafAuthenticationFailureHandler {

	@Resource(name = "fsFraudService")
	protected FraudService fraudService;

	protected String defaultFailureUrl;

    public FSAuthenticationFailureHandler() {
        super();
    }

    public FSAuthenticationFailureHandler(String defaultFailureUrl) {
        super(defaultFailureUrl);
        this.defaultFailureUrl = defaultFailureUrl;
    }
    
	@Override
	public void onAuthenticationFailure(HttpServletRequest request,
			HttpServletResponse response, AuthenticationException exception)
			throws IOException, ServletException {

		fraudService.noitfyFraudLoginResult(request, Boolean.FALSE);
		super.onAuthenticationFailure(request, response, exception);

	}
}
